package org.example.Config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;
import java.io.IOException;

@Configuration
public class FilesConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        File dir = new File("src/main/resources/imgs/");
        try {
            registry.addResourceHandler("/images/**").addResourceLocations("file:"+dir.getCanonicalPath()+File.separator);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
